package com.tom.architect02.mnbase.annotation.jvms.juc.juc4;

import java.util.concurrent.TimeUnit;

/// 拒绝策略
public class PoolRejectPolicy implements RejectPolicy<Runnable>{

    long timeout;
    TimeUnit timeUnit;

    public PoolRejectPolicy(long timeout, TimeUnit timeUnit) {
        this.timeout = timeout;
        this.timeUnit = timeUnit;
    }

    @Override
    public void reject(ClassBlockingQueue<Runnable> queue, Runnable task) {
        queue.poll(timeout, timeUnit);
    }
}
